/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uk.ac.shef.kinect_speech;

import com.primesense.nite.SkeletonState;
import com.primesense.nite.UserData;
import com.primesense.nite.UserTracker;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.PrintStream;
import java.util.List;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author samf
 */
class KinectSpeechApp {

    KinectSpeechUtils mu;
    int score = 0;
    boolean simonSays;
    long lastRequest;
    boolean announcedTracking;
    UserData activeUser;
    boolean greeted;
    long endOfRequest;
    boolean requestMade;
   
    int userCount;
    boolean kinectRecording;
    long pendingGoodbye;
    private long startedWaiting;
    private boolean pendingGoodbyeSpoken;
    int roundCount;
    PrintStream saveState;
    public KinectSpeechApp(UserTracker tracker, PositionPanel panel) {
        
        pendingGoodbyeSpoken = false;
        mu = new KinectSpeechUtils(tracker, panel);
        requestMade = false;
        try {
            BufferedReader reader = new BufferedReader(new FileReader("config/saved-state.txt"));
            String line;
            int lastPattern =0;
            while ((line=reader.readLine())!=null) {
                lastPattern = Integer.parseInt(line);
            }
            saveState = new PrintStream("config/saved-state.txt");
        } catch (Exception ex) {
            Logger.getLogger(KinectSpeechApp.class.getName()).log(Level.SEVERE, null, ex);
        }
        userCount = 0;
    }

   

    boolean isAnyoneTracking(List<UserData> users) {
        boolean isAnyoneTracking = false;
        for (UserData user : users) {
            if (user.getSkeleton().getState() == SkeletonState.TRACKED) {
                isAnyoneTracking = true;
            }
        }
        return isAnyoneTracking;
    }

    void update(List<UserData> users) {
   

    }

   

    boolean anyoneInZone(List<UserData> users) {
        boolean anyoneInZone = false;
        for (UserData user : users) {
            if (mu.newPlayZone(user)) {
              
            //if (mu.inPlayZone(user)) {
                anyoneInZone = true;
            }
        }
        return anyoneInZone;
    }

    UserData getActiveUser(List<UserData> users) {
        UserData chosenUser = null;
        for (UserData user : users) {
            if (mu.newPlayZone(user)) {
              
            //if (mu.inPlayZone(user)) {
                chosenUser = user;
            }
        }
        return chosenUser;
    }

    
}
